
//管理请求
define(["core.request","core"],function(request,core)
{
	var simpleGet=request.util.simpleGet;
	var simplePost=request.util.simplePost;
	
	var manageRequest={};
	
	manageRequest.menu=
	{
		//返回菜单
		findMenu:function(callback)
		{
			simpleGet("/manage/menu/",{},callback);
		}
	};
	
	manageRequest.config=
	{
		//返回配置
		find:function(callback)
		{
			simpleGet("/manage/config/",{},callback);
		},
		//更新
		update:function(id,name,value,callback)
		{
			simplePost("/manage/config/update/"+id,{name:name,value:value},callback);
		}
	};
	
	manageRequest.illegalChar=
	{
		//返回
		find:function(callback)
		{
			simpleGet("/manage/illegalChar/",{},callback);
		},
		//创建
		create:function(name,replace,source,callback)
		{
			simplePost("/manage/illegalChar/create",{name:name,replace:replace,source:source},callback);
		},
		//更新
		update:function(id,name,replace,source,callback)
		{
			simplePost("/manage/illegalChar/update/"+id,{name:name,replace:replace,source:source},callback);
		},
		//删除
		remove:function(id,callback)
		{
			simplePost("/manage/illegalChar/delete/"+id,{},callback);
		}
	};
	
	manageRequest.openApi=
	{
		//返回
		find:function(callback)
		{
			simpleGet("/openApi/",{},callback);
		},
		//创建
		create:function(name,url,format,request_type,parameter,explain,result,parent,index,callback)
		{
			simplePost("/openApi/create",{name:name,url:url,format:format,request_type:request_type,parameter:parameter,explain:explain,result:result,parent:parent,index:index},callback);
		},
		//更新
		update:function(id,name,url,format,request_type,parameter,explain,result,parent,index,callback)
		{
			simplePost("/openApi/update/"+id,{name:name,url:url,format:format,request_type:request_type,parameter:parameter,explain:explain,result:result,parent:parent,index:index},callback);
		},
		//删除
		remove:function(id,callback)
		{
			simplePost("/openApi/delete/"+id,{},callback);
		}
	};
	
	manageRequest.module=
	{
		//返回类型
		findType:function(callback)
		{
			simpleGet("/manage/module/type",{},callback);
		},
		//根据类型返回
		findByType:function(type,callback)
		{
			simpleGet("/manage/module/type/"+type,{},callback);
		}
	};
	
	manageRequest.user=
	{
		//搜索
		search:function(account,username,pn,callback)
		{
			simpleGet("/user/search",{account:account,username:username,pn:pn},callback);
		},
		//更新角色
		updateRole:function(id,role,callback)
		{
			simplePost("/user/"+id+"/role/update",{role:role},callback);
		},
		//踢下线
		kick:function(id,callback)
		{
			simplePost("/user/kick",{id:id},callback);
		},
		role:
		{
			//返回类型
			findType:function(callback)
			{
				simpleGet("/user/role/type",{},callback);
			},
			//更新类型
			update:function(id,name,callback)
			{
				simplePost("/user/role/type/update/"+id,{name:name},callback);
			},
			//删除类型
			remove:function(id,target,callback)
			{
				simplePost("/user/role/type/delete/"+id,{target:target},callback);
			},
			//根据角色和类型返回
			findByRoleAndType:function(role,type,callback)
			{
				simpleGet("/user/role/"+role+"/type/"+type,{},callback);
			},
			//更新角色模块
			updateModuleByRole:function(role,type,modules,callback)
			{
				simplePost("/user/role/"+role+"/module/update",{modules:modules,type:type},callback);
			},
			//设置默认
			setDefault:function(role,callback)
			{
				simplePost("/user/role/default/update",{id:role},callback);
			},
			//创建
			create:function(name,callback)
			{
				simplePost("/user/role/create",{name:name},callback);
			}
		},
		bar:
		{
			//返回
			find:function(callback)
			{
				simpleGet("/user/bar/",{},callback);
			},
			//创建
			create:function(icon,text,url,click,parent,index,callback)
			{
				simplePost("/user/bar/create",{icon:icon,text:text,url:url,click:click,parent:parent,index:index},callback);
			},
			//更新
			update:function(id,icon,text,url,click,parent,index,callback)
			{
				simplePost("/user/bar/update/"+id,{icon:icon,text:text,url:url,click:click,parent:parent,index:index},callback);
			},
			//删除
			remove:function(id,callback)
			{
				simplePost("/user/bar/delete/"+id,{},callback);
			},
			role:
			{
				//根据角色返回
				findByRole:function(role,callback)
				{
					simpleGet("/user/bar/role/"+role,{},callback);
				},
				//更新
				update:function(role,barRoles,callback)
				{
					simplePost("/user/bar/role/update",{role:role,barRoles:barRoles},callback);
				}
			}
		},
		menu:
		{
			//返回
			find:function(callback)
			{
				simpleGet("/user/menu/",{},callback);
			},
			//创建
			create:function(icon,text,url,parent,main,index,callback)
			{
				simplePost("/user/menu/create",{icon:icon,text:text,url:url,parent:parent,main:main,index:index},callback);
			},
			//更新
			update:function(id,icon,text,url,parent,main,index,callback)
			{
				simplePost("/user/menu/update/"+id,{icon:icon,text:text,url:url,parent:parent,main:main,index:index},callback);
			},
			//删除
			remove:function(id,callback)
			{
				simplePost("/user/menu/delete/"+id,{},callback);
			},
			role:
			{
				//根据角色返回
				findByRole:function(role,callback)
				{
					simpleGet("/user/menu/role/"+role,{},callback);
				},
				//更新
				update:function(role,menuRoles,callback)
				{
					simplePost("/user/menu/role/update",{role:role,menuRoles:menuRoles},callback);
				}
			}
		},
		active:
		{
			type:
			{	
				//返回动态类型
				find:function(callback)
				{
					simpleGet("/user/active/type",{},callback);
				},
				//更新
				update:function(id,name,message,url,callback)
				{
					simplePost("/user/active/type/update/"+id,{name:name,message:message,url:url},callback);
				}
			}
		},
		mail:
		{
			type:
			{
				//返回
				find:function(callback)
				{
					simpleGet("/user/mail/type",{},callback);
				},
				//更新
				update:function(id,name,text,callback)
				{
					simplePost("/user/mail/type/update/"+id,{name:name,text:text},callback);
				}
			},
			system:
			{
				//返回
				find:function(pn,callback)
				{
					simpleGet("/user/mail/system",{},callback);
				},
				//创建
				create:function(title,content,role,callback)
				{
					simplePost("/user/mail/system/create",{title:title,content:content,role:role},callback);
				}
			}
		}
	};
	
	manageRequest.software=
	{
		//返回正在审核的
		findCheck:function(pn,callback)
		{
			simpleGet("/software/check",{pn:pn},callback);
		},
		//审核通过
		checkPass:function(id,callback)
		{
			simplePost("/software/check/pass/"+id,{},callback);
		},
		//审核失败
		checkFailure:function(id,callback)
		{
			simplePost("/software/check/failure/"+id,{},callback);
		},
		//更新
		update:function(id,name,title,icon,home_page,doc_url,download_url,introduce,callback)
		{
			simplePost("/software/update/"+id,{name:name,title:title,icon:icon,home_page:home_page,doc_url:doc_url,download_url:download_url,introduce:introduce},callback);
		}
	};
	
	manageRequest.plugin=
	{
		//返回插件
		find:function(callback)
		{
			simpleGet("/manage/plugin/",{},callback);
		},
		//设置激活
		setEnabled:function(id,enabled,callback)
		{
			simplePost("/manage/plugin/setEnabled/"+id,{enabled:enabled},callback);
		},
		//移除插件
		remove:function(id,callback)
		{
			simplePost("/manage/plugin/remove/"+id,{},callback);
		}
	};
	
	manageRequest.discuss=
	{
		//返回已删除
		findDelete:function(pn,callback)
		{
			simpleGet("/discuss/delete",{pn:pn},callback);
		},
		//恢复已删除
		recoverDelete:function(id,callback)
		{
			simplePost("/discuss/recover/delete/"+id,{},callback);
		},
		//板块
		forum:
		{
			//返回
			find:function(callback)
			{
				simpleGet("/discuss/forum/",{},callback);
			},
			//创建
			create:function(name,check,index_type,index,callback)
			{
				simplePost("/discuss/forum/create",{name:name,check:check,index_type:index_type,index:index},callback);
			},
			//更新
			update:function(id,name,check,index_type,index,callback)
			{
				simplePost("/discuss/forum/update/"+id,{id:id,name:name,check:check,index_type:index_type,index:index},callback);
			},
			//首页
			index:function(callback)
			{
				simpleGet("/discuss/forum/index",{},callback);
			}
		},
		//排序
		order:
		{
			//返回
			find:function(callback)
			{
				simpleGet("/discuss/order/",{},callback);
			},
			//创建
			create:function(name,color,font,index,callback)
			{
				simplePost("/discuss/order/create",{name:name,color:color,index:index},callback);
			},
			//更新
			update:function(id,name,color,font,index,callback)
			{
				simplePost("/discuss/order/update/"+id,{name:name,color:color,font:font,index:index},callback);
			},
			//设置默认
			setDefault:function(id,callback)
			{
				simplePost("/discuss/order/default/"+id,{},callback);
			}
		},
		//返回审核
		findCheck:function(pn,callback)
		{
			simpleGet("/discuss/check",{pn:pn},callback);
		},
		//审核通过
		checkPass:function(id,callback)
		{
			simplePost("/discuss/check/pass/"+id,{},callback);
		},
		//审核不通过
		checkFailure:function(id,callback)
		{
			simplePost("/discuss/check/failure/"+id,{},callback);
		},
		report:
		{
			//返回
			find:function(pn,callback)
			{
				simpleGet("/discuss/report",{pn:pn},callback);
			},
			//根据ID返回
			findById:function(id,callback)
			{
				simpleGet("/discuss/report/concrete/"+id,{},callback);
			}
		},
		//删除
		remove:function(id,callback)
		{
			simplePost("/discuss/delete/"+id,{},callback);
		}
	};
	
	manageRequest.upload=
	{
		config:
		{
			//返回
			find:function(callback)
			{
				simpleGet("/upload/config/",{},callback);
			},
			//更新
			update:function(id,name,path,size,type,callback)
			{
				simplePost("/upload/config/update/"+id,{id:id,name:name,path:path,size:size,type:type},callback);
			}
		},
		record:
		{
			//返回
			find:function(pn,callback)
			{
				simpleGet("/upload/config/record",{pn:pn},callback);
			}
		}
	};
	
	manageRequest.friendlink=
	{
		//返回
		find:function(callback)
		{
			simpleGet("/friendlink/",{},callback);
		},
		//创建
		create:function(name,text,url,explain,color,font,index,callback)
		{
			simplePost("/friendlink/create",{name:name,text:text,url:url,explain:explain,color:color,font:font,index:index},callback);
		},
		//更新
		update:function(id,name,text,url,explain,color,font,index,callback)
		{
			simplePost("/friendlink/update/"+id,{name:name,text:text,url:url,explain:explain,color:color,font:font,index:index},callback);
		},
		//删除
		remove:function(id,callback)
		{
			simplePost("/friendlink/delete/"+id,{},callback);
		}
	};
	
	manageRequest.dongtan=
	{
		//返回已删除
		findDelete:function(pn,callback)
		{
			simpleGet("/dongtan/delete",{pn:pn},callback);
		},
		//恢复已删除
		recoverDelete:function(id,callback)
		{
			simplePost("/dongtan/recover/delete/"+id,{},callback);
		}
	};
	
	manageRequest.blog=
	{
		order:
		{
			//返回排序
			find:function(callback)
			{
				simpleGet("/blog/order/",{},callback);
			},
			//创建
			create:function(name,index,callback)
			{
				simplePost("/blog/order/create",{name:name,index:index},callback);
			},
			//更新
			update:function(id,name,index,callback)
			{
				simplePost("/blog/order/update/"+id,{name:name,index:index},callback);
			}
		},
		recommend:
		{
			//返回自荐
			find:function(pn,callback)
			{
				simpleGet("/blog/recommend/",{pn:pn},callback);
			},
			//通过
			pass:function(id,callback)
			{
				simplePost("/blog/recommend/pass/"+id,{},callback);
			},
			//拒绝
			refuse:function(id,callback)
			{
				simplePost("/blog/recommend/refuse/"+id,{},callback);
			}
		}
	};
	
	manageRequest.favorite=
	{
		type:
		{
			//返回类型
			find:function(callback)
			{
				simpleGet("/favorite/type/",{},callback);
			},
			//更新
			update:function(id,name,url,callback)
			{
				simplePost("/favorite/type/update/"+id,{name:name,url:url},callback);
			}
		}
	};
	
	manageRequest.comment=
	{
		//恢复已删除
		recoverDelete:function(id,callback)
		{
			simplePost("/comment/recover/delete/"+id,{},callback);
		},
		//删除
		remove:function(id,callback)
		{
			simplePost("/comment/delete/"+id,{},callback);
		},
		//返回删除
		findDelete:function(pn,callback)
		{
			simpleGet("/comment/delete",{pn:pn},callback);
		},
		report:
		{
			//返回
			find:function(pn,callback)
			{
				simpleGet("/comment/report",{pn:pn},callback);
			},
			//根据ID返回
			findById:function(id,callback)
			{
				simpleGet("/comment/report/concrete/"+id,{},callback);
			}
		}
	};
	
	manageRequest.cache=
	{
		node:
		{
			//返回
			find:function(pn,callback)
			{
				simpleGet("/manage/cache/node/",{pn:pn},callback);
			},
			//更新
			update:function(id,host,port,callback)
			{
				simplePost("/manage/cache/node/update/"+id,{host:host,port:port},callback);
			},
			//创建
			create:function(host,port,callback)
			{
				simplePost("/manage/cache/node/create",{host:host,port:port},callback);
			},
			//删除
			remove:function(id,callback)
			{
				simplePost("/manage/cache/node/delete/"+id,{},callback);
			}
		}
	};
	
	return manageRequest;
});